﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GUI.LuuVietHeThong
{
    public partial class frmQuanLy : Form
    {
        public frmQuanLy()
        {
            InitializeComponent();
        }

        private void frmQuanLy_Load(object sender, EventArgs e)
        {
            LoadData();
        }
        private Entities.LuuVietHeThong[] lv;
        #region Select
        private void LoadData()
        {
            lv = Common.StaticVariable.InterfaceObject.SelectLuuViet();
            dgvHienThi.DataSource = lv;
            dgvHienThi.Columns[0].HeaderText = "Mã nhân viên";
            dgvHienThi.Columns[1].HeaderText = "Tên đăng nhập";
            dgvHienThi.Columns[2].HeaderText = "Hành động";
            dgvHienThi.Columns[3].HeaderText = "Thời gian";
            dgvHienThi.Columns[4].HeaderText = "Nội dung";
        }
        #endregion
        #region Xoa
        private void Xoa()
        {
            Common.StaticVariable.InterfaceObject.DeleteLuuViet();
            LoadData();
        }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            Xoa();
        }
        #endregion
        #region Text Changed
        private void txtTimKiem_TextChanged(object sender, EventArgs e)
        {
            
            Entities.LuuVietHeThong[] temp;
            temp = lv.Where(s => s.MaNhanVien.ToLower().Contains(txtTimKiem.Text.ToLower())).ToArray<Entities.LuuVietHeThong>();
            if (temp != null)
                dgvHienThi.DataSource = temp;
            else
                dgvHienThi.DataSource = new Entities.LuuVietHeThong[0];
        }
        #endregion

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        
    }
}
